package org.example;

class Solution {
    int getWeight(char c) {
        return c == 'R' ? 1 : -1;
    }

    public int balancedStringSplit(String s) {
        int weight = 0;
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            weight += getWeight(s.charAt(i));
            if (weight == 0) {
                ans++;
            }
        }
        return ans;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}